package designpattern.myproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;


public class BussinessProxy implements InvocationHandler {
    private Object target;
    public Object newProxy(Object target){
        this.target =target;
        return Proxy.newProxyInstance(target.getClass().getClassLoader(),target.getClass().getInterfaces(),this);
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("执行前");
        method.invoke(target,args);
        System.out.println("执行后");
        return proxy;
    }
}
